// 统一管理项目接口
import request from './request'; // 引入配置了的 axios（带有请求和响应的拦截器）

function toFormData(jsonObject) {
  const formData = new FormData();
  Object.keys(jsonObject).forEach((key) => {
    formData.append(key, jsonObject[key]);
  });
  return formData
}

function toJson(formData) {
  var jsonData = {};
  formData.forEach((value, key) => jsonData[key] = value);
  return jsonData
}

// 登录
export const login = (data) => request({
  url: '/login',
  method: 'post',
  data: toFormData(data)
});
export const logout = () => request.get('/logout');
export const userInfo = () => request.get('/users/info');
